﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Vici.Mvc;
using Ss.Model;
using Vici.CoolStorage;
namespace web
{
    public class SysMenu : AdminController
    {
        [View("Admin/System/SysMenu")]
        [Url("Admin/System/SysMenu")]
        public void Run()
        {
            ViewData["PageTitle"] = "菜单管理";
        }

        [Url("Admin/System/GetMenuList")]
        public void GetMenuList()
        {
            CSList<Menu> menulist = Menu.OrderedList("ID");
            Response.Write(Menu.EasyPage("ID", true, false, "ID", "FID", "MenuName", "MenuUrl"));
            Response.End();
        }
        [Url("Admin/System/SaveMenu")]
        public void SaveMenu()
        {
            int id = Request.Form["ID"] != null ? int.Parse(Request.Form["ID"]) : 0;
            Response.Write(Menu.GridSave(id));
            Response.End();
        }
        [Url("Admin/System/DelMenu")]
        public void DelMenu()
        {
            int id = Request.Form["ID"] != null ? int.Parse(Request.Form["ID"]) : 0;
            CSList<Menu> menu = Menu.List("FID=@FID", "@FID", id);
            int count = menu.Count;
            for (int i = 0; i < count; i++)
            {
                menu[i].Delete();
            }
            Response.Write(Menu.Read(id).Delete());
            Response.End();
        }
    }
}